package mn.idax.exchange.otc.web;

import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import mn.idax.exchange.common.bean.ResponseData;
import mn.idax.exchange.otc.constant.ReferenceExchageConstant;
import mn.idax.exchange.otc.constant.RequestUrlConstant;
import mn.idax.exchange.otc.domain.MarketPairs;
import mn.idax.exchange.otc.entity.ExchageMarketPrice;
import mn.idax.exchange.otc.enums.response.OTCAdResponseEnum;
import mn.idax.exchange.otc.enums.response.SystemStatusResponseEnum;
import mn.idax.exchange.otc.exception.IdaxException;
import mn.idax.exchange.otc.service.OTCPayModeDetailService;
import mn.idax.exchange.otc.service.impl.MemoryService;
import mn.idax.exchange.otc.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: .jension
 * @Date: 2018/11/12
 * @Description:
 */

@Api(value = "参考交易所", tags = {"参考交易所"})
@RequestMapping(RequestUrlConstant.REFERENCE_EXCHANGE)
@RestController
public class ReferenceExchageController {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private OTCPayModeDetailService otcPayModeDetailService;


    /**
     * 获取对标交易所
     */
    @ApiOperation(value = "获取对标交易所", notes = "获取对标交易所")
    @RequestMapping(value = RequestUrlConstant.GET_EXCHANGE_PRICE, method = RequestMethod.POST)
    public ResponseData create(@RequestBody MarketPairs marketPairs) throws Exception {
        /*String redisKey = ReferenceExchageConstant.redisExchangeFileName + ":" + marketPairs.getMarketPairs();*/
//        if (exchageMarketPrices.isEmpty()) {
//            throw new IdaxException(OTCAdResponseEnum.EXCHANGE_PRICE_EMPTY.getCode());
//        }*/

//        otcPayModeDetailService.changeFloatingPrice(exchageMarketPrices,marketPairs);
        List<ExchageMarketPrice> exchageMarketPrices = JSONArray.parseArray(MemoryService.SYSTEMSETTINGMAP.get(marketPairs.getMarketPairs().toUpperCase()).toString(), ExchageMarketPrice.class);
        return ResponseData.success(exchageMarketPrices);
    }


}